class Card {
	private char suit;
	private int rank;
	private static final int TEN_RANK = 8;
	private static final int NUMBER_OF_RANKS = 12;
	Card(final int initrank, final char initsuit) throws PokerException {
		if (initsuit != 'h' && initsuit != 'd' && initsuit != 'c' && initsuit != 's') {
            throw new PokerException("Such card doesn't exist!");
        } else {
            suit = initsuit;
        }
		if (initrank < 0 || initrank > NUMBER_OF_RANKS) {
            throw new PokerException("Such card doesn't exist!");
        } else {
            rank = initrank;
        }
	}
	@Override
	public String toString() {
		String result;
		if (this.rank <= TEN_RANK) {
			result = Integer.toString(this.rank + 2);
		} else if (this.rank == TEN_RANK + 1) {
            result = "J";
        } else if (this.rank == TEN_RANK + 2) {
            result = "Q";
        } else if (this.rank == TEN_RANK + 3) {
            result = "K";
        } else {
            result = "A";
        }
		return result + this.suit;
	}

	char getSuit() {
		return suit;
	}
	int getRank() {
		return rank;
	}
}
